package org.geekbang.projects.cs.im.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.geekbang.projects.cs.im.packet.LoginRequestPacket;

/**
 * @description:
 * @author: Kaijun Chen
 * @date: 2023/3/15
 **/
public class LoginHandler extends ChannelInboundHandlerAdapter {

    private String userid;

    private String userName;

    public LoginHandler(String userid, String userName) {
        this.userid = userid;
        this.userName = userName;
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        loginRequestPacket.setUserId(userid);
        loginRequestPacket.setUserName(userName);
        ctx.channel().writeAndFlush(loginRequestPacket);
    }
}
